package com.cy.pj.common.web;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.rmi.ServerException;

/**
 * @author Cx
 * @stage secondStageOfWeb
 * @creat 2020-11-09 14:44
 */
@RestControllerAdvice
/* 此注解描述的类为全局异常处理类 等效于 @ControllerAdvice + @ResponseBody */
public class GlobalExceptionHandler {

    @ExceptionHandler(ArithmeticException.class)
    public String doHandleArithmeticException(ArithmeticException e) {
        return "the exception msg is" + e.getMessage();
    }

    @ExceptionHandler(ServerException.class)
    public String doHandleArithmeticException(ServerException e) {
        return "the exception msg is" + e.getMessage();
    }

}
